package com.restfinder.rate.model;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;

import lombok.Getter;
import lombok.Setter;

import com.restfinder.restaurant.model.Restaurant;
import com.restfinder.user.model.User;

@Embeddable
public class RatePK implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@Getter @Setter
	private User user;
	@ManyToOne(fetch=FetchType.LAZY)
	@Getter @Setter
	private Restaurant restaurant;
	
	
	@Override
	public boolean equals(Object obj) {
		if(this == obj) return true;
		if ((obj == null) || !(obj instanceof RatePK)) {
			return false;
		}
		RatePK ratePK = (RatePK) obj;
		return (ratePK.getRestaurant().equals(restaurant) && ratePK.getUser().equals(user));
	}
	@Override
	public String toString() {
		return "RatePK : Restaurant="+restaurant+", User="+user;
	}
	
	

}
